package root.electronclass.electronclass.widget

import android.content.Context
import android.util.AttributeSet
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.content.withStyledAttributes
import root.electronclass.electronclass.R
import root.electronclass.electronclass.databinding.ViewItemHeaderBinding

/**
 *
 * @author Lokiy
 * @date 2025/6/24 21:54
 */
class ItemHeader @JvmOverloads constructor(context: Context, attributeSet: AttributeSet? = null, defStyle: Int = 0) :
    ConstraintLayout(context, attributeSet, defStyle) {

    private val itemBinding: ViewItemHeaderBinding

    var text: CharSequence?
        get() = itemBinding.itemHeaderTitle.text
        set(value) = kotlin.run { itemBinding.itemHeaderTitle.text = value }

    init {
        inflate(context, R.layout.view_item_header, this)
        itemBinding = ViewItemHeaderBinding.bind(this)
        context.withStyledAttributes(attributeSet, R.styleable.ItemHeader) {
            text = getString(R.styleable.ItemHeader_android_text)
        }
    }

}